import ajax from '@/utils/request'
// js文件想用vuex数据,导入store对象
// import store from '@/store'
// 获取频道接口
const getUserChannelsAPI = () => {
  return ajax({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}
// 获取文章列表接口
const getArticleAPI = ({ channelId, timestamp }) => {
  return ajax({
    method: 'GET',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp: timestamp || Date.now()
    }
  })
}

// 文章不喜欢
const artDislikeAPI = ({ artId }) => {
  return ajax({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: artId
    }
  })
}

// 文章举报
const artReportAPI = ({ artId, type, remark }) => {
  return ajax({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: artId,
      type,
      remark
    }
  })
}

const getChannelListAPI = () => {
  return ajax({
    url: '/v1_0/channels'
  })
}

const updataUserChannelListAPI = ({ channels }) => {
  return ajax({
    method: 'PUT',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}

export {
  getUserChannelsAPI,
  getArticleAPI,
  artDislikeAPI,
  artReportAPI,
  getChannelListAPI,
  updataUserChannelListAPI
}
